/**
 * @file: index.
 * @intro: 全局配置文件.
 * @author: zzmhot.
 * @email: zzmhot@163.com.
 * @Date: 2017/5/8 16:38.
 * @Copyright(©) 2017 by thinkive.
 *
 */
import {sessionStorage,cookieStorage} from 'common/storage'
//本地存储的前缀
export const storage_prefix = 'zzm_admin_storage_'
//base64加密前缀
export const base64_prefix = 'zzm_admin_base64_'
//接入服务器接口地址根目录
export const server_base_url = '/'


export const functionCodes = {
  existCodes: function (code) {

    let values = cookieStorage.get("functionCodes");

    for (let i = 0; i < values.length; i++) {
      if (values[i] == code) {
        return true;
      }
    }
    return false;
  }
}

export const houseConstData = {
  houseOrientation: [],
  roomNumOptions: [],
  regionOptions: [],
  railStationOptions: [],
  houseImageTypeNameOption: [],
  tagOptions: [],
  roleOptions: [],
  identifyOptions: [],
  contactsSexOptions: [],
  contactsStateOptions: [],
  contactsTimeOptions: [],
  houseDelegationFlagOptions: [],
  rentOption: [],

  getOptionLabel: function (value, optoins) {
    for (let i = 0; i < optoins.length; i++) {
      if (optoins[i].value == value) {
        return optoins[i].label;
      }
    }
    return ""
  },
  getHouseDelegationFlagOptionName: function (value) {
    return this.getOptionLabel(value, this.houseDelegationFlagOptions)
  },
  getContactsStateOptionsName: function (value) {
    return this.getOptionLabel(value, this.contactsStateOptions)

  },
  getContactsSexOptionsName: function (value) {
    return this.getOptionLabel(value, this.contactsSexOptions)

  },
  getContactsTimeOptionsName: function (value) {
    return this.getOptionLabel(value, this.contactsTimeOptions)

  },
  /**
   * 获取站名，地铁名称
   * @param id
   * @param stationId
   */
  getRailNameAndStationName: function (id, stationId) {

    let arr = [];
    for (let i = 0; i < this.railStationOptions.length; i++) {
      let temp = this.railStationOptions[i];
      if (temp.value == id) {
        arr[0] = temp.label;

        let children = temp.children;

        for (let j = 0; j < children.length; j++) {
          if (children[j].value == stationId) {
            arr[1] = children[j].label;
          }
        }
      }
    }
    return arr;
  },


}
